package com.laboratory.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.laboratory.listener.DeviceListener;
import com.laboratory.mapper.DeviceMapper;
import com.laboratory.model.dto.device.DeviceQueryDto;
import com.laboratory.model.entity.Device;
import com.laboratory.model.vo.device.DeviceEeVo;
import com.laboratory.model.vo.device.DeviceVo;
import com.laboratory.service.DeviceService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device>
    implements DeviceService{

    @Override
    public List<DeviceVo> getAll(Integer pIndex, Integer pSize, DeviceQueryDto deviceQueryDto) {
        PageHelper.startPage(pIndex, pSize);
        return baseMapper.getAll(deviceQueryDto);
    }

    @Override
    public void importDevice() {
        EasyExcel.write("D:\\实验室设备.xlsx", DeviceEeVo.class).sheet("设备").doWrite(baseMapper.getExportDate());
    }

    @Override
    public void joinDevice() {
        EasyExcel.read("D:\\实验室设备.xlsx",DeviceEeVo.class,new DeviceListener(baseMapper)).sheet("设备").doRead();
    }
}




